﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<title>SilverMap</title>

	<script runat="server">
		protected void Page_Load( object sender, EventArgs e ) {
			friendlyUsername.Text = QUT.Bio.Web.LoginState.FriendlyLoginName;
		}

		protected void LoginStatus1_LoggedOut( object sender, EventArgs e ) {
			QUT.Bio.Web.LoginState.Clear();
		}
	
	</script>

</head>
<body style="margin:0px; overflow:hidden;" >
	<form id="form1" runat="server">
		<div id='loginPanel' 
            style="float: right; text-align:right; width: 100%; background-color: #FFFFFF; height: 30px; vertical-align: middle; padding-right: 10px;">
			<asp:Image ID="openIdUsernameImage" runat="server" EnableViewState="false" ImageUrl="~/images/openid_login.gif" />
			<asp:Label ID="friendlyUsername" runat="server" EnableViewState="false" Text=""></asp:Label>
			<asp:LoginStatus ID="LoginStatus1" runat="server" OnLoggedOut="LoginStatus1_LoggedOut" />
		</div>
		<div id='silverlightControlHost' style='width: 100%; height: 700px'>

			<script type='text/javascript'>
				function onSilverlightError(sender, args) {

					var appSource = '';
					if (sender != null && sender != 0) {
						appSource = sender.getHost().Source;
					}
					var errorType = args.ErrorType;
					var iErrorCode = args.ErrorCode;

					var errMsg = 'Unhandled Error in Silverlight 2 Application ' + appSource + '\n';

					errMsg += 'Code: ' + iErrorCode + '    \n';
					errMsg += 'Category: ' + errorType + '       \n';
					errMsg += 'Message: ' + args.ErrorMessage + '     \n';

					if (errorType == 'ParserError') {
						errMsg += 'File: ' + args.xamlFile + '     \n';
						errMsg += 'Line: ' + args.lineNumber + '     \n';
						errMsg += 'Position: ' + args.charPosition + '     \n';
					}
					else if (errorType == 'RuntimeError') {
						if (args.lineNumber != 0) {
							errMsg += 'Line: ' + args.lineNumber + '     \n';
							errMsg += 'Position: ' + args.charPosition + '     \n';
						}
						errMsg += 'MethodName: ' + args.methodName + '     \n';
					}

					throw new Error(errMsg);
				}
			</script>

			<object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='100%' height='100%'>
				<param name='source' value='ClientBin/SilverMap.xap' />
				<param name='onerror' value='onSilverlightError' />
				<param name='background' value='white' />
				<param name='minRuntimeVersion' value='4.0.30128' />
				<param name='autoUpgrade' value='true' />
				<a href='http://go.microsoft.com/fwlink/?LinkID=124807' style='text-decoration: none;'>
					<img alt='Get Microsoft Silverlight' src='http://go.microsoft.com/fwlink/?LinkId=108181' style='border-style: none' />
				</a>
				<!-- SilverMap configuration -->
				<param name='AutoLoad' value='True'/>
				<param name='DistanceType' value='EValue' />
				<param name='Cutoff' value='0.5'/>
				<param name='ReferenceGene' value='31931'/>
				<param name='Subjects' value='NC_008253.1;NC_008563.1;NC_010468.1;NC_004431.1;NC_009801.1;NC_009800.1;NC_000913.2;NC_011601.1;NC_002655.2;NC_011353.1;NC_002695.1;NC_011415.1;NC_010498.1;NC_007946.1'/>
				<param name='Selected' value='3157;7391;9992;17569;17571;22808;27491;31931;36778;42292;48148;53445;58432;63212;68296'/>
				<param name='MapWebServiceAddress' value='http://localhost:3864/MapService.asmx'/>
				<param name='TagWebService' value='http://bio.mquter.qut.edu.au/SilverMap/RdfTagService.asmx'/>
				<param name='UseTags' value='False'/>
			</object>
			<iframe style='visibility: hidden; height: 0; width: 0; border: 0px'></iframe>
		</div>
	<script type="text/javascript">
		// Browser Window Size and Position
		// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
		// you may copy these functions but please keep the copyright notice as well
		function pageWidth() {
			return window.innerWidth ? window.innerWidth
	: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth
	: document.body != null ? document.body.clientWidth
	: null;
		}

		function pageHeight() {
			return window.innerHeight ? window.innerHeight
	: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight
	: document.body != null ? document.body.clientHeight
	: null;
		}

		function posLeft() {
			return typeof window.pageXOffset != 'undefined' ? window.pageXOffset
	: document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft
	: document.body.scrollLeft ? document.body.scrollLeft
	: 0;
		}

		function posTop() {
			return typeof window.pageYOffset != 'undefined' ? window.pageYOffset
	: document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop
	: document.body.scrollTop ? document.body.scrollTop
	: 0;
		}

		function posRight() {
			return posLeft() + pageWidth();
		}

		function posBottom() {
			return posTop() + pageHeight();
		}

		var div = document.getElementById('silverlightControlHost');
		var loginPanel = document.getElementById('loginPanel');

		function resizeHandler() {
			var width = pageWidth();
			var height = pageHeight();
			
			var loginHeight = loginPanel.clientHeight ? loginPanel.clientHeight : loginPanel.offsetHeight ? loginPanel.offsetHeight : 0;
			
			div.style.width = width + "px";
			div.style.height = (height - loginHeight) + "px";
		}

		function setHandlers() {
			var oldOnload = window.onload;
			var oldResize = window.onresize;

			window.onload = function() {
				if (oldOnload) {
					oldOnload();
				}

				resizeHandler();
			}

			window.onresize = function() {
				if (oldResize) {
					oldResize();
				}

				resizeHandler();
			}
		}

		setHandlers();
	</script>
	</form>
</body>
</html>
